package com.gosdk.p;


import java.util.Calendar;

import android.content.Context;
import android.content.SharedPreferences;

public class Utils {

	public static void saveSelfAdWeight(Context context, int weight) {
		SharedPreferences config = context.getSharedPreferences("config", 0);
		config.edit().putInt("weight", weight).commit();
	}
	
	public static int getSelfAdWeight(Context context) {
		return  context.getSharedPreferences("config", 0).getInt("weight", 50);
	}
	
	
	public static void saveAdDuration(Context context, int adDuration) {
		SharedPreferences config = context.getSharedPreferences("config", 0);
		config.edit().putInt("ad_duration", adDuration).commit();
	}
	
	public static int getAdDuration(Context context) {
		return  context.getSharedPreferences("config", 0).getInt("ad_duration", 3 * 3600 * 1000);
	}
	
	
	// ��λΪ
	public static void saveLastAdTime(Context context, long lastAdTime) {
		SharedPreferences config = context.getSharedPreferences("config", 0);
		config.edit().putLong("last_ad_time", lastAdTime).commit();
	}
	
	public static long getLastAdTime(Context context) {
		return  context.getSharedPreferences("config", 0).getLong("last_ad_time", Calendar.getInstance().getTimeInMillis());
	}
	
	
	// �ϴ�������ʱ��
	public static void saveLastRequestAdTime(Context context, long last_request_ad_time) {
		SharedPreferences config = context.getSharedPreferences("config", 0);
		config.edit().putLong("last_request_ad_time", last_request_ad_time).commit();
	}
	
	public static long getLastRequestAdTime(Context context) {
		return  context.getSharedPreferences("config", 0).getLong("last_request_ad_time", 0);
	}
}
